# Makefile for Board

CC = g++
UNAME := $(shell uname)

ifeq ($(UNAME), Linux)
# Linux
LIBBOARD = libboard.so
else
ifeq ($(UNAME), Darwin)
# Mac
LIBBOARD = libboard.dylib
else
# Windows
LIBBOARD = libboard.dll
endif
endif

all: Board.o $(LIBBOARD)

Board.o:
	$(CC) -fPIC -Wall -c -g -O0 -o $@ Board.cpp

libboard.so:
	rm -f $@.1.0.0 $@ $@.1 $@.1.0
	$(CC) -shared -Wl,-soname,$@.1 -o $@.1.0.0 Board.o
	ln -s $@.1.0.0 $@.1.0
	ln -s $@.1.0 $@.1
	ln -s $@.1 $@

libboard.dylib:
	$(CC) -dynamiclib -o $@ Board.o

libboard.dll:
	$(CC) -shared -o $@ Board.o

test:
ifeq ($(UNAME), Linux)
# Linux
	$(CC) -L. -lboard -o $@ test.cpp
else
ifeq ($(UNAME), Darwin)
# Mac
	$(CC) -L. -lboard -o $@ test.cpp
else
# Windows
	$(CC) -L. -lboard -o $@.exe test.cpp
endif
endif

clean:
	rm -vf test test.exe libboard.so* libboard.d* *.o
